<?php
require '../../common.inc.php';
include("xcxpay.class.php");
$paymodule = new xcxPayClass('wx6465a42f23863ec1', '6b93b437a7d8f3d9f6ceeac4cfb0ed4f', '1601180869', '83ce17342a92b23d70d7e5876f9907b1');

// 支付成功后回调页面

// $db->query("UPDATE ".DT_PRE."finance_charge SET editor='11111111111' WHERE itemid=37");

// 支付成功后修改状态
function notifydatastatus($ordersn, $result, $outdata)
{
	global $db,$DT_PRE;
	$bank = 'weixin';
	
	$itemid = intval($ordersn);
	$total_fee = $result['total_fee']/100;
	$r = $db->get_one("SELECT * FROM {$DT_PRE}finance_charge WHERE itemid='$itemid'");
	if($r) {
		
		if($r['status'] == 3) return true;
		if($r['status'] == 0) {
			$charge_orderid = $r['itemid'];
			$charge_money = $r['amount'] + $r['fee'];
			$charge_amount = $r['amount'];
			$editor = 'N'.$bank;
			if($total_fee == $charge_money) {
				require DT_ROOT.'/api/pay/success.inc.php';
				return true;
			} else {
				$note = '充值金额不匹配S:'.$charge_money.'R:'.$total_fee;
				$db->query("UPDATE {$DT_PRE}finance_charge SET status=1,receivetime='$DT_TIME',editor='$editor',note='$note' WHERE itemid=$charge_orderid");//支付失败
			}
		}
	}
}

// 支付成功后回调验证
$paymodule->notifydata();
?>